<?php 
session_start(); 
if(!isset($_SESSION['install']))
  {
    header('Location: ../');
  }

$CONF['langue'] = $_SESSION['langue'];
include('../php/langue.php');
include('top.php');

?>
<h1><?php echo $LANG[18]; ?></h1>

<?php
require_once '../php/fonctions.php';
$nofonctions = true;
require_once '../config_.php';
require_once '../php/SQL.php';

$sql = SQL::GetInstance();

$requetes = file('install.sql');
$ok = $ok2 = true;

echo '<div class="lst">';

foreach($requetes as $requete)
{
  $requete = trim($requete);
  if(eregi('^CREATE TABLE ', $requete))
    {
      //--- spa propre mais ça faisait chier :D
      $tabRequete = explode(' ', $requete);
      $table = $tabRequete[2] = $CONF['sql_prefix'].$tabRequete[2];

      $requete = implode(' ', $tabRequete);

      if($sql->createTable($requete) === false)
	{
	  echo '<blockquote class="error">'.$LANG[19].' "'.$table.'" '.''.$LANG[20].'</blockquote>';
	  $ok = false;
	}
      else
	{
	  echo '<blockquote class="allgood">'.$LANG[19].' "'.$table.'" '.''.$LANG[21].'</blockquote>';
	}
    }
}

echo '</div>';

$opt['apercu_qual']['val']   = '70';
$opt['apercu_qual']['type']  = 'numeric;5-100';

$opt['apercu_x']['val']      = '128';
$opt['apercu_x']['type']     = 'numeric;16';

$opt['apercu_y']['val']      = '128';
$opt['apercu_y']['type']     = 'numeric;16';

$opt['autoextract']['val']   = '1';
$opt['autoextract']['type']  = 'bool';

$opt['cache_dir']['val']     = './cache/';
$opt['cache_dir']['type']    = 'dir';

$opt['cache_max']['val']     = '10240';
$opt['cache_max']['type']    = 'numeric';

$opt['debug']['val']         = '0';
$opt['debug']['type']        = 'bool';

$opt['debug_sql']['val']     = '0';
$opt['debug_sql']['type']    = 'bool';

$opt['langue']['val']        = 'fr';
$opt['langue']['type']       = 'string;list';

$opt['nbr_par_page']['val']  = '20';
$opt['nbr_par_page']['type'] = 'numeric;1';

$opt['nbr_par_page_u']['val']  = '5';
$opt['nbr_par_page_u']['type'] = 'numeric;1';

$opt['save_dir']['val']      = './save/';
$opt['save_dir']['type']     = 'dir';

$opt['theme_dir']['val']     = './theme/andreas09/';
$opt['theme_dir']['type']    = 'string;list';

$opt['upload_dir']['val']    = './upload/';
$opt['upload_dir']['type']   = 'dir';

$opt['upload_max']['val']    = '2048';
$opt['upload_max']['type']   = 'numeric';

$opt['url_base']['val']      = 'http://www.monsite.com/phplister/';
$opt['url_base']['type']     = 'string';

$opt['ap_sync']['val']       = '0';
$opt['ap_sync']['type']      = 'bool';

echo '<div class="lst">';

foreach($opt as $nomOption => $uneOption)
{
  if($sql->enregistrerOption($nomOption, $uneOption['val'], $uneOption['type'], $CONF['sql_prefix']) === false)
    {
      $ok2 = false;
      echo '<blockquote class="error">'.$LANG[22].' \''.$nomOption.'\' '.$LANG[23]." <br />";
    }
  else
    {
      echo '<blockquote class="info">'.$LANG[22].' \''.$nomOption.'\' '.$LANG[24].' \''.$uneOption['val'].'\'<br />';
    }
  echo '</blockquote>';
}

echo '</div>';

if($ok && $ok2)
  {
    echo '<br />'.$LANG[25].'<a href="step-4.php">'.$LANG[26].'</a>.';
  }
else
  {
    if(!$ok)
      {
	echo '<br />'.$LANG[27];
      }
    if(!$ok2)
      {
	echo '<br />'.$LANG[30];
      }
    echo '<br >'.$LANG[28].'<a href="step-3.php">'.$LANG[29].'</a>.';
  }

include('bottom.php');
?>
